//
//  IMManager.h
//  ChangChat
//
//  Created by Cocoa on 2019/8/28.
//  Copyright © 2019 yibai. All rights reserved.
//

#import <Foundation/Foundation.h>
#import "MsgModel.h"
#import <SocketRocket/SocketRocket.h>

typedef NS_ENUM(NSUInteger, IMConnectStatus) {
    IMConnectStatus_Connecting,
    IMConnectStatus_Connected,
    IMConnectStatus_Failed, //  自动重连
    IMConnectStatus_KickedOffline//  被踢下线
};

@class IMManager;

@protocol IMManagerUserInfoUpdateDelegate <NSObject>



@end

@protocol IMManagerDelegate <NSObject>

@optional
- (void)imManager:(IMManager *_Nullable)manager connectStatusChanged:(IMConnectStatus)connectStatus;
- (void)imManager:(IMManager *_Nullable)manager receiveMsg:(MsgModel *_Nonnull)msgModel;
- (void)imManager:(IMManager *_Nullable)manager receiveFriendStatusMsg:(MsgItem *_Nonnull)msg;
- (void)imManager:(IMManager *_Nullable)manager recallMsg:(MsgItem *_Nonnull)msg;
- (void)imManager:(IMManager *_Nullable)manager readMsg:(MsgItem *_Nonnull)msg;

- (void)imManager:(IMManager *_Nonnull)manager sendMsgSuccess:(MsgModel *_Nonnull)msgModel;
- (void)imManager:(IMManager *_Nonnull)manager sendMsgFailed:(MsgModel *_Nonnull)msgModel;

/////  收到好友信息更新
//- (void)imManagerReceiveUserInfoUpdate:(FriendItem *_Nonnull)friendItem;
- (void)imManagerNeedBindUserId;

@end

NS_ASSUME_NONNULL_BEGIN

@interface IMManager : NSObject

@property (nonatomic, strong) SRWebSocket *webSocket;
@property (nonatomic, strong, readonly) NSPointerArray *delegates;
@property (nonatomic, assign) BOOL isBindUserId;
@property (nonatomic, assign) BOOL isReady;
@property (nonatomic, assign) BOOL isNeedPullMsg;
@property (nonatomic, assign, readonly) IMConnectStatus connectStatus;
@property (nonatomic, copy, readonly) NSString *client_id;

+ (instancetype)shareManager;
@property (nonatomic, weak) id<IMManagerDelegate> bindUidDelegate;
- (void)addIMDelegate:(id<IMManagerDelegate>)delegate;
- (void)removeIMDelegate:(id<IMManagerDelegate>)delegate;
- (void)connect;
- (void)reConnect;
- (void)closeConnect;
- (void)clean;
- (void)sendMsg:(MsgModel *)msgModel;
- (void)resendMsg:(MsgModel *)msgModel;

- (NSInteger)getSendMessageId;

@end

NS_ASSUME_NONNULL_END
